import Vue from 'vue'
// 过滤器
// 时间过滤器
Vue.filter('formatDate', (time) => {
  const dateTime = new Date(time * 1000)
  const year = dateTime.getFullYear()
  const month = (dateTime.getMonth() + 1 + '').padStart(2, '0')
  const date = (dateTime.getDate() + '').padStart(2, '0')
  const hour = (dateTime.getHours() + '').padStart(2, '0')
  const minute = (dateTime.getMinutes() + '').padStart(2, '0')
  const second = (dateTime.getSeconds() + '').padStart(2, '0')
  return `${year}-${month}-${date} ${hour}:${minute}:${second}`
})

// 性别过滤器
Vue.filter('genderName', (gender) => {
  switch (gender) {
    case 0:
      return '保密'
    case 1:
      return '男'
    case 2:
      return '女'
    default:
      return '未知'
  }
})

// 状态过滤器
Vue.filter('statusName', (status) => {
  switch (status) {
    case 1:
      return '正常'
    case 2:
      return '禁用'
    default:
      return '未知'
  }
})
